﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    Periodical journal = ViewBag.Journal;
    ViewBag.Title = "期刊出版 -- " + journal.Name;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<div id="content-header">
    <h1>
        期刊出版</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/magazine/index" class="tip-bottom"><i class="icon-home"></i>起始页</a> <a href="javascript:"
        class="current">期刊出版</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box" style="margin-top: 0px;">
                <div class="widget-title">
                    <span class="icon"><i class="icon-file"></i></span>
                    <h5>
                        期刊出版</h5>
                    <div class="buttons" style="margin-right: 15px;">
                        <a href="/workspace/magazine/newpublish" class="btn btn-success btn-mini"><i class="icon-plus icon-white">
                        </i>新增期</a>
                    </div>
                </div>
                <div class="widget-content nopadding">
                @if (ViewBag.C != null && ViewBag.C == -1)
                {
                <span class="alert alert-error">上传附件不能超过20MB，如果需要上传超过20MB文件请联系管理员</span>
                } 
                <div class="widget-box">
                        <div class="widget-content nopadding">
                            <ul class="recent-posts">
                                @{
                                    ItemListBox<MagazineItem> data = ViewBag.Data;
                                    if (data != null && data.Data != null)
                                    {
                                        foreach (var item in data.Data)
                                        {
                                    <li>
                                        <div class="user-thumb">
                                            <img style="width:40px; height:40px;" alt="journal" src="@item.CoverImage">
                                        </div>
                                        <div class="article-post">
                                            <span class="user-info">第 @item.Manuscriptcode 期
                                                @if (item.Status == JournalItemStatus.Create)
                                                {
                                                    <font style="color: Orange; font-weight: bold;">[筹备中]</font>
                                                    if (String.IsNullOrEmpty(item.PagePath))
                                                    {
                                                    <p>
                                                        稿件未选定
                                                    </p>
                                                    }
                                                    else
                                                    {
                                                    <p>
                                                        稿件已选定
                                                    </p>
                                                    }
                                                }
                                                else
                                                {
                                                    <font style="color: Green; font-weight: bold;">[已出版]</font>
                                                    <p>
                                                        稿件已选定
                                                    </p>
                                                }
                                            </span>
                                            @if (item.Status == JournalItemStatus.Create)
                                            {
                                                <a href="javascript:;" onclick="LoadUploadControl(@item.Id)" class="btn btn-primary btn-mini">
                                                    选择稿件</a> 
                                            }
                                            @if (item.Status == JournalItemStatus.Create)
                                            {
                                                <a href="javascript:;" onclick="publish(@item.Id)" class="btn btn-success btn-mini">
                                                    确定出版</a> 
                                                <a href="javascript:;" onclick="deletejournalitem(@item.Id)"
                                                        class="btn btn-danger btn-mini">删除</a>
                                            }
                                        </div>
                                    </li>
                                        }
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
<div id="fileuploadframe" style="display: none; width: 950px; height: 480px;">
    <div style="display: block; height: 25px; width: 100%; border-bottom: 1px solid #ccc">
        <div style="float: right; width: 80px; height: 23px; line-height: 23px;">
            <a href="javascript:;">
                <img alt="关闭" style="border: none;" id="btnflfclose" src="/content/img/closelabel.gif" /></a>
        </div>
    </div>
    <form id="uploadform" action="/workspace/magazine/publishmagazineItem" enctype="multipart/form-data"
    method="post">
    <input type="hidden" name="journalItemId" id="hidjournalItemId"/>
    <div style="display: block; height: 340px; width: 100%; padding-top: 10px;">
        <div style="float: left; width: 10%; text-align: center;">
            本期摘要：
        </div>
        <div style="width: 87%; float: right;">
            <script name="Information" id="editor" class="{required:true}" type="text/plain"></script>
        </div>
    </div>
    <div style="display: block; height: 45px; width: 100%; padding-top: 10px;">
        <div style="float: left; width: 10%; text-align: center;">
            稿件：
        </div>
        <div style="width: 87%; float: right;">
            <input type="file" id="fleArticle" name="articles" class="{required:true, accept:'rar|zip|pdf|7z'}" />
            <span>不超过20MB</span>
        </div>
    </div>
    <div style="display: block; height: 45px; width: 100%; padding-top: 10px; border-top: 1px solid #ccc;">
        <input type="submit" class="btn btn-primary" value="提交" />
    </div>
    </form>
</div>
@section tail{
    <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_all_min.js"></script>
    <script type="text/javascript" src="/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/scripts/jquery.metadata.js"></script>
    <script type="text/javascript">
        var plug = new plug.PopFrame();
        var editor;
        $(function () {
            $('#likpublish').addClass('open active');
        });
        function deletejournalitem(id) {
            if (confirm('您确定删除此期吗？')) {
                window.location.href = '/workspace/magazine/deletejournalItem?journalItemId=' + id;
            }
        }
        function publish(id, count) {
            if (confirm('您确定要出版此期吗？此期一共选定：' + count + " 篇稿件")) {
                window.location.href = '/workspace/magazine/publishmagazineItem?journalItemId=' + id;
            }
        }
        function LoadUploadControl(id) {
            $('#hidjournalItemId').val(id);
            plug.OpenFrame('fileuploadframe', 'btnflfclose', function () {
                editor = UE.getEditor('editor', { initialFrameWidth: 800, initialFrameHeight: 280 });
                $('#uploadform').validate({
                    errorClass: "help-inline",
                    errorElement: "span",
                    highlight: function (element, errorClass, validClass) {
                        $(element).parents('.control-group').addClass('error');
                    },
                    unhighlight: function (element, errorClass, validClass) {
                        $(element).parents('.control-group').removeClass('error');
                    }
                });
            }, function () {
                editor.destroy();
            });
        }
    </script>
}
